package ch02.graphics;

import java.awt.*;

import javax.swing.*;

@SuppressWarnings("serial")
public class NameComponent extends JComponent 
{
	String name = "Shit nigga";
	
	public NameComponent(String n)
	{
		name = n;
	}
	
	public NameComponent()
	{
	}
	
	@Override
	public void paintComponent(Graphics g)
	{
		Graphics2D g2 = (Graphics2D) g;
		
		Rectangle frame = new Rectangle(50, 50, 50, 50);
		g2.draw(frame);
		
		Rectangle background = new Rectangle(20, 20, getWidth() - 20,getHeight() - 20);
		g2.setColor(Color.BLUE);
		g2.fill(background);
		
		g2.setColor(Color.RED);
		g2.drawString(name, 50, 50);
	}

}
